﻿using IntelligentAgriculture.Contracts.Dto.Input;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.DescendanttransferCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DescendanttransferCommandHandler
{
	/// <summary>
	/// 获取后裔转种列表
	/// </summary>
	public class GetDescendanttransfersCommandHandler : IRequestHandler<GetDescendanttransfersCommand, PageOutput<DescendanttransferOutPut>>
	{
		/// <summary>
		/// 接口
		/// </summary>
		private readonly IDescendantTransferService _descendantTransferService;
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="descendantTransferService"></param>

		public GetDescendanttransfersCommandHandler(IDescendantTransferService descendantTransferService)
		{
			_descendantTransferService = descendantTransferService;
		}
		/// <summary>
		/// 获取后裔转种列表
		/// </summary>
		public async Task<PageOutput<DescendanttransferOutPut>> Handle(GetDescendanttransfersCommand request, CancellationToken cancellationToken)
		{
			var input = new DescendantTransferInPut()
			{
				eatTag = request.eatTag,
				pageIndex = request.pageIndex,
				endDate = request.endDate,
				pageSize = request.pageSize,
				startDate = request.startDate,
			};
			var result=await _descendantTransferService.GetDescendanttransfers(input);
			return result;
		}
	}
}
